from django.db import models
from apps.utils.base_model import BaseModel
from apps.utils.enums import UserGenderEnum


class User(BaseModel):
    """ 用户信息表 """

    wei_chat_open_id = models.CharField(
        max_length=255,
        unique=True,
        null=False,
        blank=False,
        db_index=True,
        help_text="微信open_id",
        verbose_name="微信open_id",
    )

    session_key = models.CharField(
        max_length=255,
        null=False,
        blank=False,
        help_text="微信session_key",
        verbose_name="微信session_key",
    )

    nickname = models.CharField(
        max_length=255,
        null=False,
        default="",
        blank=False,
        help_text="用户昵称",
        verbose_name="用户昵称",
    )

    avatar_url = models.ImageField(
        upload_to="avatars/%Y/%m",
        null=True,
        blank=True,
        help_text="用户头像",
        verbose_name="用户头像",
    )

    gender = models.SmallIntegerField(
        choices=UserGenderEnum.choices(),
        null=False,
        blank=False,
        default=UserGenderEnum.OTHER,
        help_text="用户性别",
        verbose_name="用户性别",
    )

    country = models.CharField(
        max_length=255,
        null=False,
        default="",
        blank=False,
        help_text="用户所在国家",
        verbose_name="用户所在国家",
    )

    province = models.CharField(
        max_length=255,
        null=False,
        blank=False,
        default="",
        help_text="用户所在省",
        verbose_name="用户所在省",
    )

    city = models.CharField(
        max_length=255,
        null=False,
        blank=False,
        default="",
        help_text="用户所在城市",
        verbose_name="用户所在城市",
    )

    class Meta:
        db_table = "red_envelop_users"
